package com.jming.jike.enums;

import com.jming.jike.common.BusinessException;

/**
 * 支付方式枚举
 *
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2022/04/29
 */
public enum PayMethodEnum {

    // 支付方式 1 微信, 2 支付宝
    pay_WeChat(1, "微信"),
    pay_Alipay(2, "支付宝");

    private final Integer code;
    private final String desc;

    PayMethodEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 检查支付方式
     *
     * @param code
     * @Author jinming.zhang
     * @Date 2022/4/22
     */
    public static void checkPayMethod(Integer code) {

        for (PayMethodEnum payMethodEnum : PayMethodEnum.values()) {
            if (payMethodEnum.code.equals(code)) {
                return;
            }
        }

        throw new BusinessException("支付方式不正确!");
    }
}
